<?php

	// TITLE: Home_owner AUTO MODEL
	// FILE: scaffolding/model/home_owner.php
	// AUTHOR: AUTOGEN
	// CREATED: 2015/04/20 07:49:57
	// DESCRIPTION: 
	// REQUIREMENTS: 

	$createHomeOwner = function($con, $homeOwner) {
		$sql = 'INSERT INTO home_owner (id) VALUES (';
		$sql .= $home_owner->getId() . ')';
		$sql .= ')';
		$result = mysqli_query($con, $sql);
		$id = ($result) ? mysqli_insert_id($con) : $result;
		mysqli_close($con);
		return $id;
	};

	$readHomeOwner = function($con, $id) {
		$sql = 'SELECT * FROM home_owner WHERE id = ' . $id;
		$results = mysqli_query($con, $sql);
		mysqli_close($con);
		if ($results) {
			$result = mysqli_fetch_array($results);
			$homeOwner = new HomeOwner();
			$homeOwner->setId(result[0]);
		} else {
			$homeOwner = false;
		}
		return $homeOwner;
	};

	$updateHomeOwner = function($con, $homeOwner) {
		$sql = 'UPDATE home_owner SET ';
		$sql .= 'id = ' . $home_owner->getId() ;
		$sql .= 'WHERE id = ' . id;
		$result = mysqli_query($con, $sql);
		mysqli_close($con);
		return $result;
	};

	$deleteHomeOwner = function($con, $id) {
		$sql = 'DELETE FROM home_owner WHERE id = ' . $id;
		$result = mysqli_query($con, $sql);
		mysqli_close($con);
		return $result;
	};

	$listHomeOwner = function($con) {
		$sql = 'SELECT * FROM home_owner';
		$results = mysqli_query($con, $sql);
		mysqli_close($con);
		if ($results) {
			$homeOwners = array();
			while ($result = mysqli_fetch_array($results)) {
				$homeOwner = new HomeOwner();
				$homeOwner->setId(result[0]);
				$homeOwners[] = homeOwner;
			}// end while
		} else {
			$homeOwners = false;
		}
		return $homeOwners;
	};

